//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package objects;

import common.GlobalID;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;

public class SilosBarnMaterials {
    private static final LinkedHashMap<String, ExtensionMaterialsEntry> nameToId = new LinkedHashMap();
    private static final LinkedHashMap<Integer, ExtensionMaterialsEntry> idToName = new LinkedHashMap();

    public SilosBarnMaterials() {
    }

    public static void clear() {
        nameToId.clear();
        idToName.clear();
    }

    public static void addEntry(ExtensionMaterialsEntry e) {
        e.setGlobalID(Integer.valueOf(GlobalID.create(38, nameToId.size())));
        nameToId.put(e.getName(), e);
        idToName.put(e.getGlobalID(), e);
    }

    public static Integer getPriceById(Integer id) {
        ExtensionMaterialsEntry e = (ExtensionMaterialsEntry)idToName.get(id);
        return e == null?null:e.getDefaultPrice();
    }

    public static Integer getGlobalID(String name) {
        ExtensionMaterialsEntry eme = (ExtensionMaterialsEntry)nameToId.get(name);
        return eme == null?null:eme.getGlobalID();
    }

    public static String getGlobalName(int id) {
        ExtensionMaterialsEntry eme = (ExtensionMaterialsEntry)idToName.get(Integer.valueOf(id));
        return eme == null?null:eme.getName();
    }

    public static ExtensionMaterialsEntry getById(Integer id) {
        return (ExtensionMaterialsEntry)idToName.get(id);
    }

    public static ExtensionMaterialsEntry getByName(String name) {
        return (ExtensionMaterialsEntry)nameToId.get(name);
    }

    public static List<Integer> getCityMaterials() {
        ArrayList val = new ArrayList();
        Iterator var2 = idToName.keySet().iterator();

        while(var2.hasNext()) {
            Integer id = (Integer)var2.next();
            if(GlobalID.getInstanceID(id.intValue()) > 8 && GlobalID.getInstanceID(id.intValue()) <= 15) {
                val.add(id);
            }
        }

        return val;
    }

    public static List<Integer> getFarmExtMaterials() {
        ArrayList val = new ArrayList();
        Iterator var2 = idToName.keySet().iterator();

        while(var2.hasNext()) {
            Integer id = (Integer)var2.next();
            if(GlobalID.getInstanceID(id.intValue()) > 5 && GlobalID.getInstanceID(id.intValue()) <= 8) {
                val.add(id);
            }
        }

        return val;
    }

    public static Collection<ExtensionMaterialsEntry> getMaterials() {
        return idToName.values();
    }
}
